package com.linkmed.imgserver;

import java.net.InetSocketAddress;

import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
import org.apache.mina.transport.socket.SocketAcceptor;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

public class Main {

	/** Choose your favorite port number. */
	private static final int PORT = 8080;

	public static void main(String[] args) throws Exception {
		SocketAcceptor acceptor = new NioSocketAcceptor();
		acceptor.setReuseAddress(true);
		// IoAcceptorConfig config = new SocketAcceptorConfig();
		// DefaultIoFilterChainBuilder chain = config.getFilterChain();
		DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
		// ((SocketSessionConfig)
		// config.getSessionConfig()).setReuseAddress(true);
		acceptor.setHandler(new ImgProtocolHandler());
		// Bind
		acceptor.bind(new InetSocketAddress(PORT));
		// acceptor.bind(new InetSocketAddress(PORT), new ImgProtocolHandler(),
		// config);

		System.out.println("Listening on port " + PORT);
	}
}
